package com.demo;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;

public class DemoLayout extends Activity {
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		//setContentView(R.layout.activity_demo_layout);
		LinearLayout layout = new LinearLayout(this);
		setContentView(layout);
		layout.setOrientation(LinearLayout.VERTICAL);
		TextView t = new TextView(this);
		t.setText(R.string.hello_world);		
		
		Button b = new Button(this);
		b.setText("Return Main");
		b.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
		b.setOnClickListener(new Button.OnClickListener() {
			public void onClick(View v)
			{
				Intent i = new Intent();
				i.setClass(DemoLayout.this, MainActivity.class);
				startActivity(i);
				DemoLayout.this.finish();
			}
		});
		
		layout.addView(t);
		layout.addView(b);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.demo_layout, menu);
		return true;
	}
}
